package com.xjoyt.pay.master.repository;

import java.util.List;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.Query;

import com.xjoyt.pay.master.dao.ChannelRepositoryCustom;
import com.xjoyt.pay.master.po.Channel;
import com.xjoyt.pay.repository.Repository;

public interface ChannelRepository extends Repository<Channel>, ChannelRepositoryCustom {

	List<Channel> findAllByIdIn(List<String> ids);

	@Query(" select a from Channel a where a.company.id in ?1 ")
	List<Channel> findAllByIdCompanyIdIn(List<String> companyIds);

	@Query(" select a from  Channel a left join a.companyChannels c where a.company.id = ?1 or c.company.id = ?1 ")
	Page<Channel> findAllByCanUse(String companyId, Pageable pageable);

	List<Channel> findAllByHealthEnabledAndHealthUrlIsNotNull(Boolean healthEnabled);
}
